package com.quanyan.travel.service.impl;

import com.quanyan.travel.constants.OutdoorConstants;
import com.quanyan.travel.entity.TbCommonParameter;
import com.quanyan.travel.entity.TbCommonParameterExample;
import com.quanyan.travel.mapper.TbCommonParameterMapper;
import com.quanyan.travel.service.TravelBaseService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单Service
 * Created by yangyun on 2016/4/19.
 */


@Service("travelBaseService")
public class TravelBaseServiceImpl implements TravelBaseService {

    private static Logger logger = Logger.getLogger(TravelBaseServiceImpl.class);

    @Autowired
    private TbCommonParameterMapper tbCommonParameterMapper;


    @Override
    public List<TbCommonParameter> queryTbCommonParameters(String groupKey) {
        TbCommonParameterExample example = new TbCommonParameterExample();
        TbCommonParameterExample.Criteria criteria = example.createCriteria();
        criteria.andIsDeleteEqualTo(OutdoorConstants.IS_NOT_DELETE);
        criteria.andParameterGroupEqualTo(groupKey);
        return tbCommonParameterMapper.selectByExample(example);

    }

    @Override
    public TbCommonParameter getTbCommonParameter(String parameterKey) {
        TbCommonParameterExample example = new TbCommonParameterExample();
        TbCommonParameterExample.Criteria criteria = example.createCriteria();
        criteria.andIsDeleteEqualTo(OutdoorConstants.IS_NOT_DELETE);
        criteria.andParameterKeyEqualTo(parameterKey);
        List<TbCommonParameter> result=tbCommonParameterMapper.selectByExample(example);
        if (result!=null && result.size() == 1) {
            return result.get(0);
        }
        return null;
    }
}
